<!-- eslint-disable vue/multi-word-component-names -->
<script setup lang="ts">
import { MagicStick } from '@element-plus/icons-vue'
import { useTheme } from '@/composables/useTheme'

const { themeList, activeThemeName, setTheme } = useTheme()
</script>

<template>
  <div>
    <el-dropdown trigger="click">
      <div>
        <el-tooltip effect="dark" content="主题模式" placement="bottom">
          <el-icon :size="20">
            <MagicStick />
          </el-icon>
        </el-tooltip>
      </div>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item
            v-for="(theme, index) in themeList"
            :key="index"
            :disabled="activeThemeName === theme.name"
            @click="(e: MouseEvent) => setTheme(e, theme.name)"
          >
            <span>{{ theme.title }}</span>
          </el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </div>
</template>

<style lang="scss" scoped>
.home {
  color: red;
}
</style>
